<%@ page language="java" contentType="text/html; charset=UTF-8" import="entity.Goods" import="java.util.*" import="java.sql.*"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>show goods</title>
</head>
<body>
	<table width="60%" border="1">
		<thead>
		 <tr>
			<th align="center"> 编号</th>
			<th align="center"> 商品</th>
			<th align="center"> 价格</th>
			<th align="center"> 购买数量</th>
			</tr>	
		</thead>
		<tbody>
		<%
			List<Goods> list=new ArrayList<Goods>();
			list.add(new Goods(1,"笔记本",100,200));
			list.add(new Goods(2,"书本",200,200));
			list.add(new Goods(3,"玩具",300,200));
			for(int i=0;i<list.size();i++){   
			%><tr>
		      <td align="center"> <%= list.get(i).getId()%>  </td>
			  <td align="center"> <%= list.get(i).getName()%>  </td>
			  <td align="center"> <%= list.get(i).getPrice()%>  </td>
			  <td align="center"> <%= list.get(i).getNum()%> </td>	
			  </tr>
			<% } %>	
		<tr> <td colspan="6"><a href="Continue.jsp">继续购物</a> </td> </tr>
		</tbody>	
	</table>

	<script language="javascript">
		function del(){
			var coon=new ActiveXObject("ADODB.Connnection");
			var rs=new ActiveXObject("ADODB.Recordset");
			try{
				var obj=document.getElementById('del').value;
				var trid=obj.parentNode.parentNode.id;
				var trobj=document.getElementById(trid);
				
				var connectionstring="Driver={MySQL ODBC 5.2w Driver};Server=127.0.0.1;Database=mysql;User=root;Password=87552624xy;Option=3;Port=3306";
				coon.open(connectionstring);
				var sql="delete from shopcart where id="+obj+""";
				coon.execute(sql);
				coon.close();
				conn=null;

				document.getElementById("del").removeChild(trObj);
				alert("dele ok");
			}
		}
	</script>
	<td ><input id='del' type="text" size=3/><input type="button" value="删除" onclick="del()"/></td>
	
	<script language="javascript">
		funciton modify(){
			var coon=new ActiveXObject("ADODB.Connnection");
			var rs=new ActiveXObject("ADODB.Recordset");
			try{
				var id=document.getElementById('modify1').value;
				var num=document.getElementById('modify2').value;
				var connectionstring="Driver={MySQL ODBC 5.2w Driver};Server=127.0.0.1;Database=mysql;User=root;Password=87552624xy;Option=3;Port=3306";
				coon.open(connectionstring);
				var sql="update shopcart set num="+num+" where id="+id+"";
				coon.execute(sql);
				coon.close();
				conn=null;
				alert("modify ok");
		}
	</script>
	<td>&nbsp&nbsp&nbsp&nbsp修改编号为<input id='modify1' type="text" size=3 id='modify1'/>的购买数量<input id='modify2' type="text" size=3/><input type="button" id="modify" value="修改"  onclick="modify()"/>
</body>
</html>